package org.smr.ministore.micro.client;

import java.util.List;

import org.blade.utils.Pager;
import org.smr.ministore.entities.OrganAuthority;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import feign.hystrix.FallbackFactory;

@Component
public class HystrixOrganAuthorityClientFactory implements FallbackFactory<FeignOrganAuthorityMicroServiceClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HystrixOrganAuthorityClientFactory.class);

    @Override
    public FeignOrganAuthorityMicroServiceClient create(Throwable cause) {
        HystrixOrganAuthorityClientFactory.LOGGER.info("fallback; reason was: {}", cause.getMessage());

        return new OrganAuthorityFeignClientWithFactory() {

            @Override
            public OrganAuthority queryById( Long id ) {
                OrganAuthority entity = new OrganAuthority();
                entity.setId(-1L);
                return entity;
            }

            @Override
            public int batchSave( List< OrganAuthority> entities){
                return 0;
            }



            public int save(OrganAuthority entity){
                return 0;
            }

            public int updateById(OrganAuthority id){
                return 0;
            }

            public int deleteById(Long id){
                 return 0;
            }

            public Pager<OrganAuthority> paginate( OrganAuthority entity, Long pageSize, Long pageNum){
                Pager<OrganAuthority> pager = new Pager<OrganAuthority>();
                return pager;
            }

        };//Return end
    }
}